﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Forms;

namespace client.render
{
    internal class DynamicObjectCreator : ObjectCreator
    {
        static System.Timers.Timer timer = new System.Timers.Timer();

        static DynamicObjectCreator(){

            timer.Enabled = true;
            timer.Interval = 100;
            timer.Start();
        }

        public DynamicObjectCreator(Form form, int xLocationOffset, int yLocationOffset) : base(form, xLocationOffset, yLocationOffset)
        {
        }

        protected override void beforeRender(List<Image> imageList, PictureBox pictureBox)
        {
            int index = 0;

            timer.Elapsed += (object sender, ElapsedEventArgs e) =>
            {

                index = (index + 1) % imageList.Count;
                pictureBox.Image = imageList[index];
            };
           
        }
    }
}
